<?php
//删除相册
define('IN_TG', true);
define('IN_JS', true);
define('SCRIPT', true);
session_start();
require('includes/common.inc.php');
//删除处理
if (isset($_GET['id'])) {
    $tgid = intval($_GET['id']);
    $sql = "select tg_id from tg_dir where tg_id = $tgid and tg_username='{$_SESSION['username']}' limit 1";
    $res1 = _fetch_array($sql);
    $arr = array();
    //判断相册存在
    if (is_array($res1)) {
        while ($row = _fetch_array("select * from tg_photo where tg_sid=$tgid")) {
            _remove_Dir($row['tg_url']);
        }
        //删除相册的相片
        $sql = "delete from tg_photo where tg_sid = $tgid";
        //删除相册
        $reres = _query($sql);
        $sql = "delete from tg_dir where tg_id = $tgid";
        $reres = _query($sql);
        _location("删除成功", 'photo.php');
    } else {
        _alert_back("你没有权限删除相册");
    }
} else {
    _alert_back("请不要非法操作");
}
?>